<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>计算指定文件的 MD5 散列值</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.md5-file" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">md5_file</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.2.0, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">md5_file</span> &mdash; <span class="dc-title">计算指定文件的 MD5 散列值</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.md5-file-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>md5_file</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$filename</code></span>
   [, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$raw_output</code><span class="initializer"> = <strong><code>FALSE</code></strong></span></span>
  ] ) : <span class="type">string</span></div>

  <p class="para rdfs-comment">
   使用 <a href="http://www.faqs.org/rfcs/rfc1321" class="link external">&raquo;&nbsp;RSA 数据安全公司的 MD5 报文算法</a>计算 <code class="parameter">filename</code> 文件的 MD5 散列值并返回。该散列值为 32 字符的十六进制数字。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.md5-file-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">filename</code></dt>

     <dd>

      <p class="para">
       文件名
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">raw_output</code></dt>

     <dd>

      <p class="para">
       如果被设置为 <strong><code>TRUE</code></strong>，那么报文摘要将以原始的 16 位二进制格式返回。
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.md5-file-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功返回字符串，否则返回 <strong><code>FALSE</code></strong>。
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.md5-file-changelog">
  <h3 class="title">更新日志</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>版本</th>
       <th>说明</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>5.1.0</td>
       <td>
        函数改用流 API。这意味着能够配合封装器使用该函数，比如 <em>md5_file(&#039;http://example.com/..&#039;)</em>。
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.md5-file-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-5920">
    <p><strong>Example #1 <span class="function"><strong>md5_file()</strong></span> 使用范例</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$file&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'php-5.3.0alpha2-Win32-VC9-x64.zip'</span><span style="color: #007700">;<br /><br />echo&nbsp;</span><span style="color: #DD0000">'MD5&nbsp;file&nbsp;hash&nbsp;of&nbsp;'&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$file&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #DD0000">':&nbsp;'&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">md5_file</span><span style="color: #007700">(</span><span style="color: #0000BB">$file</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.md5-file-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="md5.html" class="function" rel="rdfs-seeAlso">md5()</a> - 计算字符串的 MD5 散列值</span></li>
    <li class="member"><span class="function"><a href="sha1_file.html" class="function" rel="rdfs-seeAlso">sha1_file()</a> - 计算文件的 sha1 散列值</span></li>
    <li class="member"><span class="function"><a href="crc32.html" class="function" rel="rdfs-seeAlso">crc32()</a> - 计算一个字符串的 crc32 多项式</span></li>
   </ul>
  </p>
 </div>

</div></div></div></body></html>